<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>CSS定位</title>

    <style>
      .box1 {
        height: 350px;
        background-color: yellowgreen;
      }

      .box-normal {
        width: 100px;
        height: 100px;
        background-color: blueviolet;
      }

      .box-relative {
        width: 100px;
        height: 100px;
        background-color: pink;
        position: relative;
        left: 20px;
        top: 20px;
      }

      .box2 {
        height: 350px;
        background-color: lightcoral;
      }

      .box-absolute {
        width: 100px;
        height: 100px;
        background-color: lightsteelblue;
        position: absolute;
        left: 120px;
        top: 20px;
      }

      .box3 {
        height: 350px;
        background-color: lightskyblue;
      }

      .box-fixed {
        width: 100px;
        height: 100px;
        background-color: darkorange;
        position: fixed;
        right: 0;
        top: 300px;
      }
    </style>
  </head>
  <body>
    <h1>相对定位</h1>
    <div class="box1">
      <div class="box-normal"></div>
      <div class="box-relative">相对定位</div>
      <div class="box-normal"></div>
    </div>

    <h1>绝对定位</h1>
    <div class="box2">
      <div class="box-normal"></div>
      <div class="box-absolute">绝对定位</div>
      <div class="box-normal"></div>
    </div>

    <h1>固定定位</h1>
    <div class="box3">
      <div class="box-normal"></div>
      <div class="box-fixed">固定定位</div>
      <div class="box-normal"></div>
    </div>
  </body>
</html>
